#ifndef CLIENTMANAGER_H
#define CLIENTMANAGER_H

// Offer client information(group, name, address, etc..)

#include <QList>
#include <QHostAddress>
#include <QStringList>

#include "Define.h"

class ClientManager
{
	public:
		ClientManager();
		bool IsValidClient(const QString &group, const QString &name) const;
		bool IsValidClient(const QString &fullName) const;
		bool IsValidAddress(const QHostAddress &addr) const;
		void RemoveAllClients();
		bool RemoveClient(const QString &group, const QString &name);
		bool AddClient(const QString &group, const QString &name, const QHostAddress &addr);
		bool UpdateClient(const QString &group, const QString &name, const QHostAddress &addr);
		bool IsNewGroup(const QString &group) const;
		int GetClientCount() const;
		void GetDisplayedNames(const QString &group, QStringList &displayedNames) const;
		bool GetClientInfo(const QHostAddress &addr, QString &name, QString &group) const;
		QHostAddress GetAddress(const QString &fullName) const;
		QHostAddress GetAddress(const QString &group, const QString &name) const;
		int GetGroupMemberCount(const QString &group) const;

	private:
		int GetClientIndex(const QString &group, const QString &name) const;
		int GetClientIndex(const QString &fullName) const;
		int GetAddressIndex(const QHostAddress &addr) const;

	private:
		QList<Client> _clients;
		QList<QString> _groups;
};

ClientManager *GetClientManager();
#define CLIENT_MANAGER (GetClientManager())

#endif // CLIENTMANAGER_H
